<?php
/* @var $this BaiVietController */
/* @var $model Baiviet */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'bai-viet-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

    <p class="note">Những trường <span class="required">*</span> bắt buộc phải nhập.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'dmnhombv_id'); ?>
        <?php
            $criteria = new CDbCriteria();
            $criteria->with = 'menu';
            $nhoms = Nhombaiviet::model()->findAll($criteria);
            $arrData;
            foreach($nhoms as $nhom){
                $arrData[$nhom->id]= $nhom->menu->name.' -//- '.$nhom->ten_nhom;
            }

            echo $form->dropDownList($model,'dmnhombv_id',$arrData);
        ?>
		<?php echo $form->error($model,'dmnhombv_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'ten_bv'); ?>
		<?php echo $form->textField($model,'ten_bv',array('size'=>100,'maxlength'=>1000,'id'=>'ten_bv')); ?>
		<?php echo $form->error($model,'ten_bv'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'link'); ?>
		<?php echo $form->textField($model,'link',array('size'=>100,'maxlength'=>1000,'id'=>'link')); ?>
		<?php echo $form->error($model,'link'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'img'); ?>
		<?php echo $form->textField($model,'img',array('size'=>100,'maxlength'=>1000, 'id'=>'img')); ?>
		<?php echo $form->error($model,'img'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'mieu_ta'); ?>
		<?php echo $form->textArea($model,'mieu_ta',array('size'=>60,'maxlength'=>3000, 'id'=>'mieu_ta')); ?>
		<?php echo $form->error($model,'mieu_ta'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'noi_dung'); ?>
		<?php echo $form->textArea($model,'noi_dung',array('rows'=>6, 'cols'=>50, 'id'=>'noi_dung')); ?>
		<?php echo $form->error($model,'noi_dung'); ?>
	</div>
<fieldset>
    <legend>Seo Website:</legend>
	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>100,'maxlength'=>1000)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'description'); ?>
		<?php echo $form->textArea($model,'description',array('cols'=>100, 'rows'=>7)); ?>
		<?php echo $form->error($model,'description'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'tag'); ?>
		<?php echo $form->textField($model,'tag',array('size'=>100,'maxlength'=>1000)); ?>
		<?php echo $form->error($model,'tag'); ?>
	</div>
</fieldset>
    <?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker'); ?>
	<div class="row">
		<?php echo $form->labelEx($model,'ngay_tao'); ?>
        <?php echo $form->dateField($model,'ngay_tao');?>
        <?php
//        $this->widget('CJuiDateTimePicker',array(
//            'language'=>'',
//            'model'=>$model,                                // Model object
//            'attribute'=>'ngay_tao', // Attribute name
//            'mode'=>'datetime',                     // Use "time","date" or "datetime" (default)
//            'options'=>array(
//                'dateFormat'=>'yy-mm-dd',
//                'altFormat'=>'yy-mm-dd',
//                'changeMonth'=>'true',
//                'changeYear'=>'true',
//                'yearRange'=>'1920:2020',
//            ),                     // jquery plugin options
//            'htmlOptions'=>array('readonly'=>true) // HTML options
//        ));
        ?>
		<?php echo $form->error($model,'ngay_tao'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'ngay_sua'); ?>
        <?php echo $form->dateField($model,'ngay_sua');?>
		<?php echo $form->error($model,'ngay_sua'); ?>
	</div>

    <div class="row">
        <?php echo $form->labelEx($model,'is_about'); ?>
        <?php echo $form->checkBox($model,'is_about'); ?>
        <?php echo $form->error($model,'is_about'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'is_home'); ?>
        <?php echo $form->checkBox($model,'is_home'); ?>
        <?php echo $form->error($model,'is_home'); ?>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'is_new'); ?>
		<?php echo $form->checkBox($model,'is_new'); ?>
		<?php echo $form->error($model,'is_new'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'is_active'); ?>
		<?php echo $form->checkBox($model,'is_active'); ?>
		<?php echo $form->error($model,'is_active'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'stt'); ?>
		<?php echo $form->textField($model,'stt'); ?>
		<?php echo $form->error($model,'stt'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->

<script type="text/javascript">
    getEditor("#mieu_ta","tiny","100%",100);
    getEditor("#noi_dung","maxi","100%",500);
    $("#img").click(function(){
        openKCFinder(this);
    });

    $("#ten_bv").focusout(function(){
        var strVN = $("#ten_bv").val();
        var strEN = UnSign(strVN);
        $("#link").val(strEN);
    })

</script>